package com.monkey.model.comparator;

import com.monkey.model.monkey.MonkeyData;

import java.util.Comparator;

/**
 * desc: auth: chenxiaobin data: 2018/1/14.
 */
public class MonkeyMyProfitComparator implements Comparator<MonkeyData> {
	private boolean order;

	public MonkeyMyProfitComparator(boolean order) {
		this.order = order;
	}

	@Override
	public int compare(MonkeyData object1, MonkeyData object2) {
		Integer g1 = object1.getGeneration();
		Integer g2 = object2.getGeneration();
		Float b1 = object1.getBonus();
		Float b2 = object2.getBonus();
		Float p1 = object1.getBonusYesterday().floatValue();
		Float p2 = object2.getBonusYesterday().floatValue();
		Float w1 = object1.getWeight();
		Float w2 = object2.getWeight();
		Float gw1 = object1.getGrow();
		Float gw2 = object2.getGrow();
		Float r1 = object1.getReproduct();
		Float r2 = object2.getReproduct();

		if (order) {
			if (p1.equals(p2)) {
				if (b1.equals(b2)) {
					if (g1.equals(g2)) {
						if (w1.equals(w2)) {
							if (gw1.equals(gw2)) {
								return r1.compareTo(r2);
							} else if (gw1 < gw2) {
								return -1;
							} else {
								return 1;
							}
						} else if (w1 < w2) {
							return -1;
						} else {
							return 1;
						}
					} else if (g1 < g2) {
						return -1;
					} else {
						return 1;
					}
				} else if (b1 < b2) {
					return -1;
				} else {
					return 1;
				}
			} else if (p1 < p2) {
				return -1;
			} else {
				return 1;
			}
		} else {
			if (p2.equals(p1)) {
				if (b2.equals(b1)) {
					if (g2.equals(g1)) {
						if (w2.equals(w1)) {
							if (gw2.equals(gw1)) {
								return r2.compareTo(r1);
							} else if (gw2 < gw1) {
								return -1;
							} else {
								return 1;
							}
						} else if (w2 < w1) {
							return -1;
						} else {
							return 1;
						}
					} else if (g2 < g1) {
						return -1;
					} else {
						return 1;
					}
				} else if (b2 < b1) {
					return -1;
				} else {
					return 1;
				}
			} else if (p2 < p1) {
				return -1;
			} else {
				return 1;
			}
		}
	}
}
